// 手写map函数
Array.prototype.myMap = function (callback, thisArg) {
  if (typeof callback !== "function") {
    throw new TypeError(callback + "mast to be a function");
  }
  if (!Array.isArray(this)) {
    throw new TypeError("this mast to be a Array");
  }

  const resultArray = [];
  const len = this.length;
  for (let i = 0; i < len; i++) {
    const resultItem = callback.call(thisArg, this[i], i, this);
    resultArray[i] = resultItem;
  }

  return resultArray;
};

const myArray = [1,2,3,4,5,6];
const result = myArray.myMap((item, index) => {
  return item + 100;
})
console.log(result);